package com.xinghou.platform.dao.main.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import com.xinghou.platform.dao.bases.JdbcTemplate;
import com.xinghou.platform.dao.bases.database.CustomerContextHolder;
import com.xinghou.platform.model.main.ShuaLiang;

@Repository
public class ShuaLiangDAOImpl  {/*
	@Resource
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public ShuaLiang getShuaLiang(int num) throws DataAccessException {
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_READ);
		String sql = "SELECT * FROM shualiang WHERE num = ?";
		ShuaLiang shuaLiang = jdbcTemplate.queryForObject(sql, new Object[] { num }, new ShuaLiangMapper());
		CustomerContextHolder.clearCustomerType();
		return shuaLiang;
	}

	@Override
	public int saveShuaLiang(ShuaLiang shuangliang) throws DataAccessException {
		StringBuffer strSQL = new StringBuffer("INSERT INTO shualiang (browse,priaise,fans,atten,num,TIME,totalnum1,totalnum2) VALUES (?,?,?,?,?,?,?,?)");
		Object[] params = {shuangliang.getBrowse(),shuangliang.getPriaise(),shuangliang.getFans(),shuangliang.getAtten(),
				shuangliang.getNum(),shuangliang.getTime(),shuangliang.getTotalnum1(),shuangliang.getTotalnum2()};
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_WRITE);
		int ret =jdbcTemplate.save(strSQL.toString(),params);
		CustomerContextHolder.clearCustomerType();
		return ret;
	}

	@Override
	public int updShuaLiang(ShuaLiang shuangliang) throws DataAccessException {
		StringBuffer strSQL = new StringBuffer("update shualiang set browse=?,priaise=?,fans=?,atten=?,num=?,TIME=?,totalnum1=?,totalnum2=? where id=?");
		Object[] params = {shuangliang.getBrowse(),shuangliang.getPriaise(),shuangliang.getFans(),shuangliang.getAtten(),
				shuangliang.getNum(),shuangliang.getTime(),shuangliang.getTotalnum1(),shuangliang.getTotalnum2(),shuangliang.getId()};
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_WRITE);
		int ret =jdbcTemplate.update(strSQL.toString(),params);
		CustomerContextHolder.clearCustomerType();
		return ret;
	}
	
	private static final class ShuaLiangMapper implements RowMapper<ShuaLiang> {
		public ShuaLiang mapRow(ResultSet rs, int rowNum) throws SQLException {
			ShuaLiang sl = new ShuaLiang();
			sl.setId(rs.getInt("id"));
			sl.setBrowse(rs.getInt("browse"));
			sl.setPriaise(rs.getInt("priaise"));
			sl.setFans(rs.getInt("fans"));
			sl.setAtten(rs.getInt("atten"));
			sl.setNum(rs.getInt("num"));
			sl.setTime(rs.getTimestamp("time"));
			sl.setTotalnum1(rs.getInt("totalnum1"));
			sl.setTotalnum2(rs.getInt("totalnum2"));
			return sl;
		}
	}*/

}
